using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Busi.Entity
{
	[Table("VehicleApply", "ID", "Busi.ConnectionString")]
	public class VehicleApply : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_ID = "ID";
		public const string SQLCOL_VEHICLEID = "VehicleID";
		public const string SQLCOL_STARTDATE = "StartDate";
		public const string SQLCOL_STARTTIME = "StartTime";
		public const string SQLCOL_ENDDATE = "EndDate";
		public const string SQLCOL_ENDTIME = "EndTime";
		public const string SQLCOL_PURPOSE = "Purpose";
		public const string SQLCOL_DESTINATION = "Destination";
		public const string SQLCOL_PEOPCOUNT = "PeopCount";
		public const string SQLCOL_NOTES = "Notes";
		public const string SQLCOL_APPLICANT = "Applicant";
		public const string SQLCOL_APPLICANTNAME = "ApplicantName";
		public const string SQLCOL_GROUPID = "GroupID";
		public const string SQLCOL_GROUPNAME = "GroupName";
		public const string SQLCOL_APPLYDATE = "ApplyDate";
		public const string SQLCOL_STATUS = "Status";
		public const string SQLCOL_AUDITUSERID = "AuditUserID";
		public const string SQLCOL_AUDITUSERNAME = "AuditUserName";
		public const string SQLCOL_AUDITTIME = "AuditTime";
		public const string SQLCOL_ORIGINID = "OriginID";
		public const string SQLCOL_REMARK1 = "Remark1";
		public const string SQLCOL_REMARK2 = "Remark2";
		public const string SQLCOL_REMARK3 = "Remark3";
		public const string SQLCOL_DRIVERID = "DriverID";
		public const string SQLCOL_DISTANCE = "Distance";
		public const string SQLCOL_KILOMETER = "Kilometer";
		public const string SQLCOL_KILOMETERMONEY = "KilometerMoney";
		public const string SQLCOL_WAITMONEY = "WaitMoney";
		public const string SQLCOL_MONEY = "Money";
		public const string SQLCOL_TICKETMONEY = "TicketMoney";
		public const string SQLCOL_WAITALLOWANCE = "WaitAllowance";
		public const string SQLCOL_ALLOWANCE = "Allowance";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public VehicleApply () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public VehicleApply (int ID)
		{
			this.ID = ID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
			VehicleID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_VEHICLEID]);
			StartDate = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_STARTDATE]);
			StartTime = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_STARTTIME]);
			EndDate = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_ENDDATE]);
			EndTime = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ENDTIME]);
			Purpose = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PURPOSE]);
			Destination = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DESTINATION]);
			PeopCount = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_PEOPCOUNT]);
			Notes = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_NOTES]);
			Applicant = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_APPLICANT]);
			ApplicantName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_APPLICANTNAME]);
			GroupID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_GROUPID]);
			GroupName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_GROUPNAME]);
			ApplyDate = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_APPLYDATE]);
			Status = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_STATUS]);
			AuditUserID = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_AUDITUSERID]);
			AuditUserName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_AUDITUSERNAME]);
			AuditTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_AUDITTIME]);
			OriginID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ORIGINID]);
			Remark1 = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_REMARK1]);
			Remark2 = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_REMARK2]);
			Remark3 = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_REMARK3]);
			DriverID = (long)ObjectType.LongTypeHelper.Read(row[SQLCOL_DRIVERID]);
			Distance = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DISTANCE]);
			Kilometer = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_KILOMETER]);
			KilometerMoney = (decimal)ObjectType.DecimalTypeHelper.Read(row[SQLCOL_KILOMETERMONEY]);
			WaitMoney = (decimal)ObjectType.DecimalTypeHelper.Read(row[SQLCOL_WAITMONEY]);
			Money = (decimal)ObjectType.DecimalTypeHelper.Read(row[SQLCOL_MONEY]);
			TicketMoney = (decimal)ObjectType.DecimalTypeHelper.Read(row[SQLCOL_TICKETMONEY]);
			WaitAllowance = (decimal)ObjectType.DecimalTypeHelper.Read(row[SQLCOL_WAITALLOWANCE]);
			Allowance = (decimal)ObjectType.DecimalTypeHelper.Read(row[SQLCOL_ALLOWANCE]);
		}

		#region Properties 
		#region Property <int> ID
		[Property("ID", 4, SqlDbType.Int, true, true)]
		public int ID 
		{
			get { return _ID; }
			set { _ID = value; }
		}
		private int _ID = int.MinValue;
		#endregion

		#region Property <int> VehicleID
		[Property("VehicleID", 4, SqlDbType.Int, false, false)]
		public int VehicleID 
		{
			get { return _VehicleID; }
			set { _VehicleID = value; }
		}
		private int _VehicleID = int.MinValue;
		#endregion

		#region Property <DateTime> StartDate
		[Property("StartDate", 16, SqlDbType.DateTime, false, false)]
		public DateTime StartDate 
		{
			get { return _StartDate; }
			set { _StartDate = value; }
		}
		private DateTime _StartDate = DateTime.MinValue;
		#endregion

		#region Property <string> StartTime
		[Property("StartTime", 20, SqlDbType.NVarChar, false, false)]
		public string StartTime 
		{
			get { return _StartTime; }
			set { _StartTime = value; }
		}
		private string _StartTime = null;
		#endregion

		#region Property <DateTime> EndDate
		[Property("EndDate", 16, SqlDbType.DateTime, false, false)]
		public DateTime EndDate 
		{
			get { return _EndDate; }
			set { _EndDate = value; }
		}
		private DateTime _EndDate = DateTime.MinValue;
		#endregion

		#region Property <string> EndTime
		[Property("EndTime", 20, SqlDbType.NVarChar, false, false)]
		public string EndTime 
		{
			get { return _EndTime; }
			set { _EndTime = value; }
		}
		private string _EndTime = null;
		#endregion

		#region Property <string> Purpose
		[Property("Purpose", 100, SqlDbType.NVarChar, false, false)]
		public string Purpose 
		{
			get { return _Purpose; }
			set { _Purpose = value; }
		}
		private string _Purpose = null;
		#endregion

		#region Property <string> Destination
		[Property("Destination", 100, SqlDbType.NVarChar, false, false)]
		public string Destination 
		{
			get { return _Destination; }
			set { _Destination = value; }
		}
		private string _Destination = null;
		#endregion

		#region Property <int> PeopCount
		[Property("PeopCount", 4, SqlDbType.Int, false, false)]
		public int PeopCount 
		{
			get { return _PeopCount; }
			set { _PeopCount = value; }
		}
		private int _PeopCount = int.MinValue;
		#endregion

		#region Property <string> Notes
		[Property("Notes", 1000, SqlDbType.NVarChar, false, false)]
		public string Notes 
		{
			get { return _Notes; }
			set { _Notes = value; }
		}
		private string _Notes = null;
		#endregion

		#region Property <string> Applicant
		[Property("Applicant", 40, SqlDbType.NVarChar, false, false)]
		public string Applicant 
		{
			get { return _Applicant; }
			set { _Applicant = value; }
		}
		private string _Applicant = null;
		#endregion

		#region Property <string> ApplicantName
		[Property("ApplicantName", 100, SqlDbType.NVarChar, false, false)]
		public string ApplicantName 
		{
			get { return _ApplicantName; }
			set { _ApplicantName = value; }
		}
		private string _ApplicantName = null;
		#endregion

		#region Property <Guid> GroupID
		[Property("GroupID", 16, SqlDbType.UniqueIdentifier, false, false)]
		public Guid GroupID 
		{
			get { return _GroupID; }
			set { _GroupID = value; }
		}
		private Guid _GroupID = Guid.Empty;
		#endregion

		#region Property <string> GroupName
		[Property("GroupName", 100, SqlDbType.NVarChar, false, false)]
		public string GroupName 
		{
			get { return _GroupName; }
			set { _GroupName = value; }
		}
		private string _GroupName = null;
		#endregion

		#region Property <DateTime> ApplyDate
		[Property("ApplyDate", 16, SqlDbType.DateTime, false, false)]
		public DateTime ApplyDate 
		{
			get { return _ApplyDate; }
			set { _ApplyDate = value; }
		}
		private DateTime _ApplyDate = DateTime.MinValue;
		#endregion

		#region Property <string> Status
		[Property("Status", 1, SqlDbType.Char, false, false)]
		public string Status 
		{
			get { return _Status; }
			set { _Status = value; }
		}
		private string _Status = null;
		#endregion

		#region Property <string> AuditUserID
		[Property("AuditUserID", 40, SqlDbType.NVarChar, false, false)]
		public string AuditUserID 
		{
			get { return _AuditUserID; }
			set { _AuditUserID = value; }
		}
		private string _AuditUserID = null;
		#endregion

		#region Property <string> AuditUserName
		[Property("AuditUserName", 100, SqlDbType.NVarChar, false, false)]
		public string AuditUserName 
		{
			get { return _AuditUserName; }
			set { _AuditUserName = value; }
		}
		private string _AuditUserName = null;
		#endregion

		#region Property <DateTime> AuditTime
		[Property("AuditTime", 16, SqlDbType.DateTime, false, false)]
		public DateTime AuditTime 
		{
			get { return _AuditTime; }
			set { _AuditTime = value; }
		}
		private DateTime _AuditTime = DateTime.MinValue;
		#endregion

		#region Property <int> OriginID
		[Property("OriginID", 4, SqlDbType.Int, false, false)]
		public int OriginID 
		{
			get { return _OriginID; }
			set { _OriginID = value; }
		}
		private int _OriginID = int.MinValue;
		#endregion

		#region Property <string> Remark1
		[Property("Remark1", 200, SqlDbType.NVarChar, false, false)]
		public string Remark1 
		{
			get { return _Remark1; }
			set { _Remark1 = value; }
		}
		private string _Remark1 = null;
		#endregion

		#region Property <int> Remark2
		[Property("Remark2", 4, SqlDbType.Int, false, false)]
		public int Remark2 
		{
			get { return _Remark2; }
			set { _Remark2 = value; }
		}
		private int _Remark2 = int.MinValue;
		#endregion

		#region Property <string> Remark3
		[Property("Remark3", 200, SqlDbType.NVarChar, false, false)]
		public string Remark3 
		{
			get { return _Remark3; }
			set { _Remark3 = value; }
		}
		private string _Remark3 = null;
		#endregion

		#region Property <long> DriverID
		[Property("DriverID", 8, SqlDbType.BigInt, false, false)]
		public long DriverID 
		{
			get { return _DriverID; }
			set { _DriverID = value; }
		}
		private long _DriverID = long.MinValue;
		#endregion

		#region Property <string> Distance
		[Property("Distance", 20, SqlDbType.NVarChar, false, false)]
		public string Distance 
		{
			get { return _Distance; }
			set { _Distance = value; }
		}
		private string _Distance = null;
		#endregion

		#region Property <int> Kilometer
		[Property("Kilometer", 4, SqlDbType.Int, false, false)]
		public int Kilometer 
		{
			get { return _Kilometer; }
			set { _Kilometer = value; }
		}
		private int _Kilometer = int.MinValue;
		#endregion

		#region Property <decimal> KilometerMoney
		[Property("KilometerMoney", 21, SqlDbType.Money, false, false)]
		public decimal KilometerMoney 
		{
			get { return _KilometerMoney; }
			set { _KilometerMoney = value; }
		}
		private decimal _KilometerMoney = decimal.MinValue;
		#endregion

		#region Property <decimal> WaitMoney
		[Property("WaitMoney", 21, SqlDbType.Money, false, false)]
		public decimal WaitMoney 
		{
			get { return _WaitMoney; }
			set { _WaitMoney = value; }
		}
		private decimal _WaitMoney = decimal.MinValue;
		#endregion

		#region Property <decimal> Money
		[Property("Money", 21, SqlDbType.Money, false, false)]
		public decimal Money 
		{
			get { return _Money; }
			set { _Money = value; }
		}
		private decimal _Money = decimal.MinValue;
		#endregion

		#region Property <decimal> TicketMoney
		[Property("TicketMoney", 21, SqlDbType.Money, false, false)]
		public decimal TicketMoney 
		{
			get { return _TicketMoney; }
			set { _TicketMoney = value; }
		}
		private decimal _TicketMoney = decimal.MinValue;
		#endregion

		#region Property <decimal> WaitAllowance
		[Property("WaitAllowance", 21, SqlDbType.Money, false, false)]
		public decimal WaitAllowance 
		{
			get { return _WaitAllowance; }
			set { _WaitAllowance = value; }
		}
		private decimal _WaitAllowance = decimal.MinValue;
		#endregion

		#region Property <decimal> Allowance
		[Property("Allowance", 21, SqlDbType.Money, false, false)]
		public decimal Allowance 
		{
			get { return _Allowance; }
			set { _Allowance = value; }
		}
		private decimal _Allowance = decimal.MinValue;
		#endregion
		#endregion


		public bool LoadByIdentity(int ID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
